from apscheduler.schedulers.background import BackgroundScheduler
from RouteManage.models import *
from RouteManage.serializers import *


def job():
    for rota in Rota.objects.all():
        rota = RotaSerializer(rota,data={"Finished": "False"})
        if rota.is_valid():
            rota.save()
        else:
            print(rota.errors)


scheduler = BackgroundScheduler()
scheduler.add_job(job, 'cron', hour=0, minute=0)
scheduler.start()
